<template>
  <view class="conference-management">
    <xbd-pages-content title="会议室预定">
      <template #content>
        <view class="content">
          <ConferenceList
            v-for="item in list"
            :key="item.id"
            :info="item"
          ></ConferenceList>
        </view>
      </template>
    </xbd-pages-content>
  </view>
</template>

<script>
import { Meeting } from "@/api/index.js";
import ConferenceList from "@/components/conferencemanagement/ConferenceList.vue";
export default {
  data() {
    return {
      list: [],
    };
  },
  components: {
    ConferenceList,
  },
  methods: {
    editInfo(name, time) {
      this.list.forEach((item) => {
        if (item.name === name) {
          item.time.push(time);
        }
      });
    },
    async init() {
      try {
        this.$showLoading("加载中");
        const res = await Meeting.getMettingRoomList();
        const {
          success,
          data: { list: data },
        } = res;
        if (success) {
          this.list = data;
        }
        uni.hideLoading();
      } catch (e) {
        uni.hideLoading();
      }
    },
  },
  onLoad() {
    this.init();
    uni.$on("appointTime", this.editInfo);
  },
  onUnload() {
    uni.$off("appointTime", this.editInfo);
  },
};
</script>

<style></style>
